'use strict';

angular.module('com.dcos.app').controller('ProjectRightController', function($window,$state, $filter, api, $uibModal,ProjectRightService) {
  var vm = this;
  vm.breadCrumbArr = [api.breadCrumbMap.projectright.root];
  vm.initPageSize = api.initPageSize;

  vm.msg="删除操作不可恢复，确定要删除？";

  vm.curProjectId=$window.sessionStorage.getItem("curProjectId");

  vm.pRightData=[];

  vm.getProjectRightList = function() {
  	vm.loading = false;

    ProjectRightService.getlist(vm.curProjectId).then(function (response) {
      if(response.data.peoplelist!=null)
        vm.pRightData=response.data.peoplelist;
      else
        vm.pRightData=[];
      vm.page = 1;

      vm.pageSize = vm.initPageSize;
      vm.totalCount = vm.pRightData.length;
      vm.itemLength = vm.totalCount;
      vm.reverse = false;
    });
  }
  vm.getProjectRightList();

  //创建
  vm.create = function()
  {
    var modalInstance = $uibModal.open({
      animation: true,
      templateUrl: 'controllers/projectright/user/user.html',
      controller: 'UserController as vm',
      resolve: {
        type:function(){return "create";},
        reload:function(){return vm.getProjectRightList;}
      }
    });
  }

  vm.fnDelete = function(project_id,userid) {
    ProjectRightService.delete(project_id,userid).then(function (response) {
      vm.getProjectRightList();
    });
  }
});

